*********************************
/* 

Do-file for: "The Correlates of Ethnicity: Why the Ethnic Majority Expects That Ethnic Minorities Contribute Less to the Collective" 
	
This dofile loads the analysis dataset and replicates the main analyses.

*/
*********************************




****************
* Load Dataset *
****************

use ".../ethnic_bias_bjps_dataset", clear




****************
* Analysis *
****************


* Figure 1 is a visualization of the study design
	
	
* Table 1 is a list of attributes and attribute levels across information treatments 


* Figure 2
	* Panel A
	reg coop_fc i.name i.born i.rel i.age_cat if treat==1, cluster(caseid) 
	eststo h1_fc 
	coefplot h1_fc, pstyle(p7) ///
		drop(_cons) xline(0) scheme(s2mono) baselevels ci(95 90) ///
		graphregion(color(white)) title("") /// 
		headings(0.name="{bf: Name}" 0.born="{bf: Born}" 0.rel="{bf: Religious}" 1.age_cat="{bf: Age group}" 1.edu="{bf: Education}" 1.res="{bf: Residence type}" 1.gender_role="{bf: Gender roles}" 1.homo="{bf: Homosexual marriage}" 1.undeclared="{bf: Undeclared work}" 1.welfare="{bf: Work status}") ///
		name(m1_a, replace)
		
	* Panel B
	reg coop i.name i.born i.rel i.age_cat if treat==1, cluster(caseid)
	eststo h1_continous
	coefplot h1_continous, pstyle(p7) ///
		drop(_cons) xline(0) scheme(s2mono) baselevels ci(95 90) ///
		graphregion(color(white)) title("") /// 
		headings(0.name="{bf: Name}" 0.born="{bf: Born}" 0.rel="{bf: Religious}" 1.age_cat="{bf: Age group}" 1.edu="{bf: Education}" 1.res="{bf: Residence type}" 1.gender_role="{bf: Gender roles}" 1.homo="{bf: Homosexual marriage}" 1.undeclared="{bf: Undeclared work}" 1.welfare="{bf: Work status}") ///
		name(m1_a, replace)

		
* Figure 3
	reg coop_fc i.name i.born i.rel i.age_cat i.edu i.res if treat==2, cluster(caseid)
	eststo h2_ses 
	reg coop_fc i.name i.born i.rel i.age_cat i.gender_role i.homo if treat==3, cluster(caseid)
	eststo h2_values
	 reg coop_fc i.name i.born i.rel i.age_cat i.undeclared i.welfare if treat==4, cluster(caseid)
	eststo h2_normcompliance
	coefplot (h2_ses, asequation("SES") \ h2_values, asequation(Cultural Values) \ h2_normcompliance, asequation(Norm Compliance) \ , pstyle(p7)), ///
	keep(1.edu 2.edu 3.edu 1.res 2.res 3.res 1.gender_role 2.gender_role 3.gender_role 1.homo 2.homo 3.homo 1.undeclared 2.undeclared 3.undeclared 1.welfare 2.welfare 3.welfare) xline(0) scheme(s2mono) baselevels ci(95 90) /// 
	graphregion(color(white)) title("") ///
	headings(1.edu="{bf: Education}" 1.res="{bf: Residence Type}" 1.gender_role="{bf: Gender Roles}" 1.homo="{bf: Homosexual Marriage}" 1.undeclared="{bf: Undeclared Work}" 1.welfare="{bf: Work Status}", labsize(small)) legend(off) yline(11 21.9, lpattern(---)) ylabel(, labsize(small)) xtick(#9) xlabel(-0.4 (0.1) 0.4)
		

* Figure 4
	* Panel A
	reg coop_fc i.name##i.treat_np i.born##i.treat_np, cluster(caseid)
	margins, dydx(name) over(treat_np) post 
	coefplot, pstyle(p7) ///
		xline(0) scheme(s2mono) baselevels ci(95 90) xscale(range(-0.15 (0.05) 0.05)) xlabel(-0.15 (0.05) 0.05)   ///
		graphregion(color(white)) title("") order(1.treat 2.treat 3.treat 4.treat 5.treat) xtitle("Average Marginal Effect of a Name", height(5)) ///
		mlabel format(%9.2g) mlabposition(12) name(m1, replace) 

	* Panel B
	reg coop_fc i.name##i.treat_np i.born##i.treat_np, cluster(caseid)
	eststo h3_name_amcie
	coefplot h3_name_amcie, pstyle(p7) ///
		keep(1.name#2.treat_np 1.name#3.treat_np 1.name#4.treat_np 1.name#5.treat_np) xline(0) scheme(s2mono) baselevels ci(95 90) xscale(range(-0.05 (0.05) 0.15)) xlabel(-0.05 (0.05) 0.15) ///
		graphregion(color(white)) title("")  ///
		mlabel format(%9.2g) mlabposition(12) name(m3, replace) ///
		coeflabels(1.name#2.treat_np = "Control vs. Socio-economy" 1.name#3.treat_np = "Control vs. Cultural values" 1.name#4.treat_np = "Control vs. Norm compliance" 1.name#5.treat_np = "Control vs. Full information")
		

	
* Figure 5
	reg coop_fc i.name i.born i.rel i.age_cat i.edu i.id_edu i.res if treat==2, cluster(caseid) 
	eststo expl_share_edu
	reg coop_fc i.name i.born i.rel i.age_cat i.edu i.res i.id_res if treat==2, cluster(caseid) 
	eststo expl_share_res
	reg coop_fc i.name i.born i.rel i.age_cat i.gender_role i.id_gender_role i.homo if treat==3, cluster(caseid) 
	eststo expl_share_gender
	reg coop_fc i.name i.born i.rel i.age_cat i.gender_role i.homo i.id_homo if treat==3, cluster(caseid) 
	eststo expl_share_homo
	reg coop_fc i.name i.born i.rel i.age_cat i.undeclared i.id_undeclared i.welfare if treat==4, cluster(caseid) 
	eststo expl_share_undeclared
	reg coop_fc i.name i.born i.rel i.age_cat undeclared i.welfare i.id_welfare if treat==4, cluster(caseid) 
	eststo expl_share_welfare
	coefplot expl_share_*, pstyle(p7) ///
		keep(1.id_*) xline(0) scheme(s2mono) baselevels ci(95 90) /// 
		graphregion(color(white)) title("") mlabel format(%9.2g) mlabposition(12) legend(off) ///
		coeflabels(1.id_rel = "Sharing religiosity" 1.id_edu = "Sharing education level" 1.id_res = "Sharing type of residence"1.id_gender_role = "Sharing view on gender roles" 1.id_homo = "Sharing view on homosexuals' rights" 1.id_undeclared = "Sharing undeclared work" 1.id_welfare = "Sharing work status")
		

* Figure 6 
	reg coop i.name##i.treat_np i.born##i.treat_np, cluster(caseid)
	margins, at(name=(0)) over(treat_np) post 
	eststo marginal_means_danish 
	reg coop i.name##i.treat_np i.born##i.treat_np, cluster(caseid)
	margins, at(name=(1)) over(treat_np) post 
	eststo marginal_means_middle_east
	coefplot (marginal_means_danish, label("Danish Name")) (marginal_means_middle_east, label("Middle Eastern Name")),	scheme(s2mono) baselevels ci(95 90) graphregion(color(white)) title("") order(1.treat 2.treat 3.treat 4.treat 5.treat) xtitle("", height(10)) mlabel format(%9.2f) mlabposition(12) coeflabels(1._at#1.treat_np="Control" 1._at#2.treat_np="Socio-economy"  1._at#3.treat_np="Cultural values"  1._at#4.treat_np="Norm compliance" 1._at#5.treat_np="Full information"  2._at#1.treat_np=" " 2._at#2.treat_np=" " 2._at#3.treat_np=" " 2._at#4.treat_np=" " 2._at#5.treat_np=" ") xscale(range(3 (0.5) 5)) xlabel(#5) relocate(*2._at#1.treat_np* = 1.3 *2._at#2.treat_np* = 2.3 *2._at#3.treat_np* = 3.3 *2._at#4.treat_np* = 4.3 *2._at#5.treat_np* = 5.3)
				
			
		
* Figure 7
	* Panel A
	reg coop_fc i.name##i.treat i.born##i.treat if treat==1 | treat==5 | treat==6, cluster(caseid)
	margins, dydx(name) over(treat) post 
	coefplot, pstyle(p7) ///
		xline(0) scheme(s2mono) baselevels ci(95 90) xscale(range(-0.15 (0.05) 0.05)) xlabel(-0.15 (0.05) 0.05)   ///
		graphregion(color(white)) title("") order(1.treat 6.treat 2.treat 3.treat 4.treat 5.treat) xtitle("Average Marginal Effect of a Name", height(5)) ///
		mlabel format(%9.2g) mlabposition(12)

	* Panel B
	reg coop_fc i.name##ib6.treat i.born##ib6.treat if treat==1 | treat==5 | treat==6, cluster(caseid)
	eststo placebo_amcie
	coefplot placebo_amcie, pstyle(p7)  ///
		keep(1.name#1.treat 1.name#2.treat 1.name#3.treat 1.name#4.treat 1.name#5.treat) xline(0) scheme(s2mono) baselevels ci(95 90) xscale(range(-0.05 (0.05) 0.15)) xlabel(-0.05 (0.05) 0.15) ///
		graphregion(color(white)) title("")  ///
		mlabel format(%9.2g) mlabposition(12) ///
		coeflabels(1.name#1.treat = "Placebo vs. Control" 1.name#5.treat = "Placebo vs. Full information")


eststo clear
		
		
	